package drds.global_transaction.api.rpc.config;

import io.netty.util.NettyRuntime;

public enum WorkThreadMode
{

	/**
	 * Auto work thread mode.
	 */
	Auto(NettyRuntime.availableProcessors() * 2 + 1),
	/**
	 * Pin work thread mode.
	 */
	Pin(NettyRuntime.availableProcessors()),
	/**
	 * Busy pin work thread mode.
	 */
	busyPin(NettyRuntime.availableProcessors() + 1),
	/**
	 * Default work thread mode.
	 */
	Default(NettyRuntime.availableProcessors() * 2);

	//
	public static WorkThreadMode getModeByName(String name)
	{
		if (Auto.name().equalsIgnoreCase(name))
		{
			return Auto;
		} else if (Pin.name().equalsIgnoreCase(name))
		{
			return Pin;
		} else if (busyPin.name().equalsIgnoreCase(name))
		{
			return busyPin;
		} else if (Default.name().equalsIgnoreCase(name))
		{
			return Default;
		} else
		{
			return null;
		}
	}

	private int value;

	WorkThreadMode(int value)
	{
		this.value = value;
	}

	public int getValue()
	{
		return value;
	}

}
